﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Butterfly.Library.Components.Security;
using Butterfly.User.Library.Components.ib_User;

namespace IboxWebSite.Controls
{
    public partial class Left : System.Web.UI.UserControl
    {
        protected void Page_Load(object sender, EventArgs e)
        {

        }

        protected override void OnInit(EventArgs e)
        {
            base.OnInit(e);
            btnlogin.Click += new EventHandler(btnlogin_Click);
        }

        private void btnlogin_Click(object sender, EventArgs e)
        {
            int userId = ib_UserLoginController.CheckPassword(txtusername.Text, txtpass.Text);

            if (userId > 0)
            {
                if (chksavepass.Checked)
                {
                    AuthenticateUtility.LoginUser(userId.ToString(), true);
                }
                else
                {
                    AuthenticateUtility.LoginUser(userId.ToString(), false);
                }

                Response.Redirect("/Home/Homepage.aspx");
            }
            
        }
    }
}